package com.snake.springboot.custom.controller.aicost;


import com.snake.springboot.custom.api.model.aicost.FormulaModel;
import com.snake.springboot.custom.api.response.aicost.FormulaRsp;
import com.snake.springboot.custom.api.service.aicost.FormulaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.snake.common.result.ResponseResult;
import org.snake.common.result.ResponseResultFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>算计公式配置
 * 类{@code Formula} </br>
 * 创建时间2025/3/20 16:57
 *
 * @author yangxt
 * @see
 */
@Api(tags = "算计公式配置")
@RestController
@RequestMapping("/formula")
public class FormulaController {


    private FormulaService formulaService;
    @Autowired
    public FormulaController(FormulaService formulaService) {
        this.formulaService = formulaService;
    }

    @ApiOperation("修改")
    @PostMapping("/modify")
    public ResponseResult<FormulaModel> modifyFormula(
            @ApiParam(name = "接口模型入参", value = "传入json格式", required = true)
            @RequestBody FormulaModel model) {
        formulaService.update(model);
        return ResponseResultFactory.ucc("修改成功！");
    }


    @ApiOperation("查询列表")
    @PostMapping("/list")
    public ResponseResult<List<FormulaRsp>> queryFormulaList(
            @ApiParam(name = "查询条件", value = "传入json类型", required = true)
            @RequestBody FormulaModel params) {
        List<FormulaRsp> result = formulaService.formulaList(params);
        return ResponseResultFactory.ucc("查询成功！", result);
    }
}
